<include file="Public:header" />
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>
<script src="__PUBLIC__/js/mxcrm_more.js" type="text/javascript"></script>
<style>
    body{
        /*overflow-y: hidden;*/
    }
    .option{padding-left:-30px;}

    .navContent li a{
        color: #75899d;
    }
    .li_text_active {
        float: left;
        background-color: #f5f5f5;
        padding-left: 10px;
        width: 100%;
        border-left: 2px solid #03a9f4;
        line-height: 32px;
        margin-bottom: 3px;
        color: #03a9f4;
    }
    .f13_c99{
        font-size: 13px;
        color: #999999;
    }
    .relitive{
        position: relative;
    }
    .count_num{
        position: absolute;
        right: 10px;
        top: 7px;
        height: 18px;
        background: #a8cbe5;
        padding: 0 10px;
        display: inline-block;
        line-height: 18px;
        color: #fff;
        border-radius: 3px;
        font-size: 12px;
        font-weight: inherit;
    }
</style>
<script>
    $(function () {
//	var scroll_width = 5;
//	$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
//	$(window).resize(function(){
//		$("#table_div").height(window.innerHeight-$("#table_div").offset().top-$("#tfoot_div").height()-parseInt($("#table_container").css("padding-bottom").replace("px",""))-10);
//		$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width());
//		$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
//	})
//	if ("{$Think.get.by}") {
//		$("#filter_ul").prev().html($("#filter_ul>li>a.active").text()+'<span class="fa fa-angle-down small_fa"></span>');
//	}
//	$("#tab_Test3").FrozenTable(1,0,3);
//	$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width).width($("#oTableLH_tab_Test3").width()).css({'zIndex':9});
//	$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width).css({'zIndex':9});
        //$("#oDivH_tab_Test3").css('top','-7px');
    })
</script>
<div class="wrapper wrapper-content">
    <include file="Public:alert" />
    <div class="row">
        <div class="col-lg-12">
            <div class="col-sm-2" style="background-color: rgb(255, 255, 255); padding: 20px; height: 566px;">
                <div class="subNavBox">
                    <div class="subNav currentDd currentDt">待操作的发票 </div>
                    <ul class="navContent" style="display:block">
                        <li>
                            <a href="{:U('invoice/index',array('type'=>'apply'))}" class="tikect" data-target="apply" id="now" ><span <if condition="$type eq 'apply'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>  >申请中的发票<label class="count_num">{$applyNum}</label></span></a>
                        </li>
                        <li>
                            <a href="{:U('invoice/index',array('type'=>'examine'))}" class="tikect" data-target="examine" ><span <if condition="$type eq 'examine'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>已审批的发票<label class="count_num">{$examineNum}</label></span></a>
                        </li>
                        <li>
                            <a href="{:U('invoice/index',array('type'=>'billing'))}" class="tikect" data-target="billing" ><span <if condition="$type eq 'billing'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>已开出发票<label class="count_num">{$billingNum}</label></span></a>
                        </li>
                                            <li>
                                                <a href="{:U('invoice/index',array('type'=>'money'))}" class="tikect" data-target="money" ><span <if condition="$type eq 'money'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>收到款发票<label class="count_num">{$moneyNum}</label></span></a>
                                            </li>
                    </ul>
                                  <div class="subNav currentDd currentDt">完成操作的发票</div>
                                    <ul class="navContent" style="display:block">
                                        <li><a href="{:U('invoice/index',array('type'=>'distribution'))}" class="tikect" data-target="distribution"><span <if condition="$type eq 'distribution'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>已分配发票<label class="count_num">{$distributionNum}</label></span></a></li>
                                        <li><a href="{:U('invoice/index',array('type'=>'grant'))}" class="tikect" data-target="grant" ><span <if condition="$type eq 'grant'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>已发放发票<label class="count_num">{$grantNum}</label></span></a></li>
                                    </ul>
                                    <div class="subNav currentDd currentDt">回撤的发票</div>
                                    <ul class="navContent" style="display:block">
                                        <li><a href="{:U('invoice/index',array('type'=>'return'))}" class="tikect" data-target="return" ><span <if condition="$type eq 'return'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>退回的发票<label class="count_num">{$returnNum}</label></span></a></li>
                                        <li><a href="{:U('invoice/index',array('type'=>'refund'))}" class="tikect" data-target="refund" ><span <if condition="$type eq 'refund'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>退款的发票<label class="count_num">{$refundNum}</label></span></a></li>
                                        <li><a href="{:U('invoice/index',array('type'=>'refuse'))}" class="tikect" data-target="refuse" ><span <if condition="$type eq 'refuse'">class="relitive li_text li_text_active"<else/>class="relitive li_text"</if>>审批驳回发票<label class="count_num">{$refuseNum}</label></span></a></li>
                                    </ul>
                </div>
            </div>

            <div class="wrapper wrapper-content animated fadeIn invoice-content" >
                <link rel="stylesheet" href="__PUBLIC__/style/css/dialog.css">
                <div class="col-sm-10 tab-content tab0" id="tab0">
                    <div class="ibox float-e-margins">
                        <div class="title-bar" style="position: relative;">
                            <div class="row titlebtns clearfix" style="display:none;">
                                <ul class="breadcrum pull-left">
                                    <input type="hidden" class="select_arr" value="">
                                    <li>已选中&nbsp;<span class="icheck_num"></span>&nbsp;项</li>
                                    <!--<li><a href="javascript:void(0)" class="btn_examine" data_type="multi"><i class="fa fa-legal"></i>&nbsp;审批</a></li>-->
                                    <li><a href="javascript:void(0)" class="excelExport"><i class="fa fa-download"></i>&nbsp;导出</a></li>
                                    <li><a  href="javascript:void(0)" class="btn_delete" data_type="multi"><i class="fa fa-times"></i>&nbsp;撤销</a></li>
                                    <if condition="$type eq 'apply'"><li><a  href="javascript:void(0)" class="btn_passed" data_type="multi"><i class="fa fa-legal"></i>&nbsp;通过</a></li></if>
                                    <li class="last_li"><big><a class="fa fa-times pull-right btnclose" id="back-show"></a></big></li>
                                </ul>
                            </div>
                            <div class="row notitlebtns">
                                <ul class="nav pull-left" style="margin:2px 0 0 35px;display: none;">
                                    <a href="{:U('invoice/add')}" class="btn btn-primary btn-sm pull-left" style="margin-right:8px"><i class="fa fa-plus-circle"></i>&nbsp; 添加发票{$type}</a>
                                </ul>
                                <form class="form-inline" id="" action="" method="get">
                                    <ul class="breadcrum pull-right" style="margin-bottom: 0px">
                                        <li>
                                            搜索：
                                            <div class="input-group">
                                                <input type="hidden" name="m" value="invoice"/>
                                                <input type="hidden" name="a" value="index"/>
                                                <input type="hidden" name="condition" value="contains"/>
                                                <input type="hidden" name="field" value="name"/>
                                                <input id="short_search" type="text" style="width:160px;" placeholder="请输入发票号码、客户名称、合同编号" onkeydown='if (event.keyCode == 13) {
                                                                    $("#short_search_btn").trigger("click");
                                                                    return false;
                                                                }' class="form-control input-sm" name="search" <if condition = "$_GET['field'] eq 'name'">value="{$_GET['search']}"</if>/>
                                                <span class="input-group-btn">
                                                    <button class="btn btn-default btn-search" id="short_search_btn" type="submit"><i class="fa fa-search"></i></button>
                                                </span>
                                            </div>
                                            &nbsp;&nbsp;<a title="高级搜索" href="javascript:void(0)" id="search_type" class="btn btn-white btn-bitbucket"><i class="fa fa-filter" style="color: #D8E3EF;"></i></a>
                                        </li>
                                        <div class="btn-group">
                                            <button data-toggle="dropdown" class="btn btn-primary dropdown-toggle" aria-expanded="false">操作 <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu">
                                                <li><a href="javascript:void(0);" class="link excelExport"><i class="fa fa-download"></i>&nbsp;导出</a></li>	                            </ul>
                                        </div>
                                    </ul>
                                </form>
                            </div>
                        </div>
                        <div class="row" style="margin: 0">
                            <div class="ibox-content" style="padding:0px;">
                                <div class="ibox-content clearfix" id="table_container" style="padding:0px;border: none;">
                                    <form id="form1" action="" method="Post" style="position:relative;">
                                        <div id="table_div" class="full-height-scroll" style="left:0px;top:0px;overflow-x: hidden;">
                                            <if condition="empty($invoice_list)">
                                                <div class="dataTables_wrapper form-inline">
                                                    <div class="row" style="margin:0;border: 1px solid #ebebeb;border-bottom: 0;border-top: 0;padding-top: 5px">
                                                        <div class="col-sm-8 row">
                                                            <div class="col-sm-2">
                                                                <select id="type_business" class="form-control">
                                                                    <option value="">全部</option>
                                                                    <option value="1">面试快</option>
                                                                    <option value="2">入职快 </option>
                                                                    <option value="3">专业猎头</option>
                                                                    <option value="4">慧简历</option>
                                                                </select>
                                                            </div>
                                                            <div class="col-sm-3" style="padding-left: 60px;">
                                                                <input value="{$type}" type="hidden" id="type"/>
                                                                <input id="applyed_time" placeholder="申请时间" class="form-control Wdate" input_type="time" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s'})" value="" type="text" />
                                                            </div>
                                                            <div class="col-sm-3">
                                                                至:<input id="applyed_endtime" class="form-control Wdate" input_type="time" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s'})" value="" type="text" />
                                                            </div>
                                                            <div class="col-sm-1">
                                                                <button class="btn btn-primary" id="shaixuan" type="button">筛选</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <include file="Public:nodata" />
                                                <else/>
                                                <div class="dataTables_wrapper form-inline">
                                                    <div class="row" style="margin:0;border: 1px solid #ebebeb;border-bottom: 0;border-top: 0;padding-top: 5px">
                                                        <div class="col-sm-9 row">
                                                            <div class="DTTT_container pull-left col-sm-2">
                                                                <div class="checkbox checkbox-primary">
                                                                    <input type="checkbox" class="check_all" name="checkall">
                                                                    <label for=""></label>
                                                                </div>
                                                                <span class="ng-binding">全选</span>
                                                            </div>
                                                            <div class="col-sm-2">
                                                                   <select id="type_business" class="form-control">
                                                                       <option value="">全部</option>
                                                                       <option value="1">面试快</option>
                                                                       <option value="2">入职快</option>
                                                                       <option value="3">专业猎头</option>
                                                                       <option value="4">慧简历</option>
                                                                   </select>
                                                            </div>
                                                            <div class="col-sm-3" style="padding-left: 60px;">
                                                                <input value="{$type}" type="hidden" id="type"/>
                                                                <input id="applyed_time" placeholder="申请时间" class="form-control Wdate" input_type="time" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s'})" value="" type="text" />
                                                                </div>
                                                            <div class="col-sm-4">
                                                                至:<input id="applyed_endtime" class="form-control Wdate" input_type="time" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd H:m:s'})" value="" type="text" />
                                                            </div>
                                                            <div class="col-sm-1">
                                                                <button class="btn btn-primary" id="shaixuan" type="button">筛选</button>
                                                            </div>
                                                        </div>
                                                        <div class="col-sm-3" style="line-height:30px">
                                                            <div class="dataTables_length pull-right"><span class="dataTables_info ng-binding" role="status">总共: {$count} 条结果</span></div>
                                                        </div>
                                                    </div>
                                                    <div class="row" style="margin-top:0">
                                                        <div class="col-sm-12">
                                                            <div style="border: 1px solid #e7eaec;border-top: 0">
                                                                <table class="table table-hover" style="margin-bottom:0">
                                                                    <tbody>
                                                                    <volist name="invoice_list" id="vo">
                                                                        <tr >
                                                                            <td class="project-title">
                                                                                <div class="col-sm-10" style="height: 24px;margin-top: 10px;">
                                                                                    <div class="checkbox checkbox-primary" style="float: left;margin-left: -8px;margin-top: -2px;">
                                                                                        <input  name="checklist" class="check_list" type="checkbox" value="{$vo.invoice_id}" rel="" rel1="" rel2="">
                                                                                        <label></label>
                                                                                    </div>
                                                                                    <span class="label label-success m-l-xs ng-binding" style="float:left">{$vo.billing_type}</span>
                                                                                    <span class="label label-primary m-l-xs ng-binding" style="float:left">{$vo.cost_type}</span>
                                                                                    <span class="label label-warning m-l-xs ng-binding" style="float:left">
                                                                                        <if condition="$vo.project_type eq 1">
                                                                                            面试快
                                                                                            <elseif  condition="$vo.project_type eq 2"/>
                                                                                            入职快
                                                                                            <elseif  condition="$vo.project_type eq 3"/> 
                                                                                            专业猎头
                                                                                            <elseif  condition="$vo.project_type eq 4"/>
                                                                                            慧简历
                                                                                            <else />
                                                                                            {$vo.project_type}
                                                                                        </if>

                                                                                    </span>
                                                                                    <strong style="color:#333333;float:left" class="ng-binding">&nbsp;{$vo['customer_name']}  &nbsp;&nbsp;</strong>
                                                                                    <span style="color:#333333;float:left" class="ng-binding">  （{$vo['project_stage']}）  &nbsp;&nbsp;</span>
                                                                                    <span style="color:#333333;float:left" class="ng-binding">  （金额：{$vo['price']}）  &nbsp;&nbsp;</span><span style="color:#333333;float:left" class="ng-binding">  （已收金额：{$vo['money']}）  &nbsp;&nbsp;</span>
                                                                                </div>
                                                                                <div class="col-sm-2 project-status text-right">
                                                                                    <if condition="$type eq 'apply'">
                                                                                        <span class="label label-warning ng-binding">申请中</span>
                                                                                        <elseif  condition="$type eq 'examine'"/>
                                                                                        <span class="label label-warning ng-binding">待开票</span>
                                                                                        <elseif  condition="$type eq 'billing'"/>
                                                                                        <span class="label label-warning ng-binding">待付款</span>
                                                                                        <elseif  condition="$type eq 'money'"/>
                                                                                        <span class="label label-warning ng-binding">待分配</span>
                                                                                        <elseif  condition="$type eq 'distribution'"/>
                                                                                        <span class="label label-success ng-binding">待发放</span>
                                                                                        <elseif  condition="$type eq 'grant'"/>
                                                                                        <span class="label label-primary ng-binding">已发放</span>
                                                                                        <elseif  condition="$type eq 'return'"/>
                                                                                        <span class="label label-warning ng-binding">发票退回</span>
                                                                                        <elseif  condition="$type eq 'refund'"/>
                                                                                        <span class="label label-warning ng-binding">发票退款</span>
                                                                                        <elseif  condition="$type eq 'refuse'"/>
                                                                                        <span class="label label-warning ng-binding">发票驳回</span>
                                                                                    </if>
                                                                                </div>
                                                                                <div class="col-sm-12 p_l_30"  style="height: 24px;">
                                                                                    <small><span class="f13_c99 mr_5">公司名称:</span><a target="_blank" href="{:U('customer/view', 'id='.$vo['customer_id'])}" style="color: #0693CD;font-weight: 400;font-size: 12px">{$vo['customer_name']}</a></small>
                                                                                    <small><span class="f13_c99 ml_20 mr_5">职位名称:</span><a target="_blank" href="{:U('business/view','id='.$vo['business_id'])}" style="color: #0693CD;font-weight: 400;font-size: 12px">{$vo['business_name']}</a></small>
                                                                                    <small><span class="f13_c99 ml_20 mr_5">候选人:</span><a target="_blank"  href="{:U('product/view', 'id='.$vo['eid'])}" style="color: #0693CD;font-weight: 400;font-size: 12px">{$vo['resume_name']}</a></small>
                                                                                </div>
                                                                                <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                    <small><span class="f13_c99 mr_5">备注:</span>{$vo['description']}</small>
                                                                                </div>
                                                                                <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                    <small><span class="f13_c99 mr_5">申请人:</span><a style="color: #0693CD;font-weight: 400;font-size: 12px" class="ng-binding role_info"  rel="{$vo['create_role_id']}"> {$vo['user_name']}</a></small>
                                                                                    <small><span class="f13_c99 ml_20 mr_5">申请日期:</span><span>{$vo['create_time']|date='Y-m-d H:i',###}</span></small>
                                                                                    <small><span class="f13_c99 ml_20 mr_5">发票编号:</span><span>{$vo['name']}</span></small>
                                                                                </div>
                                                                        <if condition="$vo['examine_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">审批备注:</span>
                                                                                    {$vo['examine_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['examine_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <if condition="$vo['billing_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">开票时间:</span>
                                                                                    {$vo['billing_content']['ctime']}
                                                                                    <span class="f13_c99 ml_20 mr_5">开票备注:</span>
                                                                                    {$vo['billing_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['billing_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <if condition="$vo['money_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">到款金额:</span>
                                                                                    {$vo['money_content']['amount']}
                                                                                    <span class="f13_c99 ml_20 mr_5">到款时间:</span>
                                                                                    {$vo['money_content']['ctime']}
                                                                                    <span class="f13_c99 ml_20 mr_5">备注:</span>
                                                                                    {$vo['money_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['money_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <if condition="$vo['refund_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">退款金额:</span>
                                                                                    {$vo['refund_content']['number']}
                                                                                    <span class="f13_c99 ml_20 mr_5">退款时间:</span>
                                                                                    {$vo['refund_content']['gjtime']}
                                                                                    <span class="f13_c99 ml_20 mr_5">备注:</span>
                                                                                    {$vo['refund_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['refund_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <if condition="$vo['grant_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">发放时间:</span>
                                                                                    {$vo['grant_content']['gjtime']}
                                                                                    <span class="f13_c99 ml_20 mr_5">备注:</span>
                                                                                    {$vo['grant_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['grant_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <if condition="$vo['return_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">退票时间:</span>
                                                                                    {$vo['return_content']['gjtime']}
                                                                                    <span class="f13_c99 ml_20 mr_5">备注:</span>
                                                                                    {$vo['return_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['return_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <if condition="$vo['back_content']">
                                                                            <div class="col-sm-12 p_l_30" style="height: 24px;">
                                                                                <small>
                                                                                    <span class="f13_c99 mr_5">回退备注:</span>
                                                                                    {$vo['back_content']['description']}
                                                                                    <span class="f13_c99 ml_20 mr_5">操作时间:</span>
                                                                                    {$vo['back_content']['addtime']|date='Y-m-d H:i',###}
                                                                                </small>
                                                                            </div>
                                                                        </if>
                                                                        <div class="col-sm-12">
                                                                            <div class="project-actions pull-right">
                                                                                <ul class="nav">
                                                                                    <li style="display:inline-block">
                                                                                        <button class="btn btn-white btn-xs btn_edit" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-pencil"></i>编辑</button>
                                                                                    </li>
                                                                                    <if condition="$type eq 'apply'">
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_examine" type="button" data-id="{$vo['invoice_id']}"  data_type="single"><i class="fa fa-legal"></i>审批</button>
                                                                                        </li>
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_delete" type="button" data-id="{$vo['invoice_id']}" data_type="single"><i class="fa fa-times"></i>撤销</button>
                                                                                        </li>
                                                                                        <elseif  condition="$type eq 'examine'"/>
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_count" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-legal"></i>开票</button>
                                                                                        </li>
<!--                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_return" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-reply"></i>回退</button>
                                                                                        </li>-->
                                                                                        <elseif  condition="$type eq 'billing'"/>
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_bill" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-rmb"></i>收款</button>
                                                                                        </li>
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_refund" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-rotate-right"></i>退票</button>
                                                                                        </li>
<!--                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_return" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-reply"></i>回退</button>
                                                                                        </li>-->
                                                                                        <elseif  condition="$type eq 'money'"/>
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_assign" type="button" data-id="{$vo['invoice_id']}" data-type="{$vo.project_type}"><i class="fa fa-pie-chart"></i>分配</button>
                                                                                        </li>
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_refuse" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-rotate-right"></i>退款</button>
                                                                                        </li>
<!--                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_return" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-reply"></i>回退</button>
                                                                                        </li>-->
                                                                                        <elseif condition="$type eq 'distribution'" />
                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_sendout" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-pie-chart"></i>发放</button>
                                                                                        </li>

<!--                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_return" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-reply"></i>回退</button>
                                                                                        </li>-->
                                                                                        <elseif condition="$type eq 'grant'" />

<!--                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_return" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-reply"></i>回退</button>
                                                                                        </li>-->
                                                                                        <elseif condition="$type eq 'return' || $type eq 'refund'|| $type eq 'refuse' " />
<!--                                                                                        <li style="display:inline-block">
                                                                                            <button class="btn btn-white btn-xs btn_return" type="button" data-id="{$vo['invoice_id']}"><i class="fa fa-reply"></i>回退</button>
                                                                                        </li>-->
                                                                                    </if>
                                                                                </ul>
                                                                            </div>
                                                                        </div>
                                                                        </td>
                                                                        </tr>
                                                                    </volist>
                                                                    </tbody>
                                                                </table>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <table class="table table-hover table-striped table_thead_fixed" id="tab_Test3" style="background:#fff;margin-bottom:0px;"></table>
                                            </if>
                                        </div>
                                        <div id="tfoot_div" class="clearfix">
                                            <tr>
                                            <div class="clearfix" id="tfoot_page">
                                                {$page}<include file="Public:listrows" />
                                            </div>
                                            </tr>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-check-invoice" title="发票审核">
                    <form action="" id="contract_dialog" method="post">
                        <input id="dialog_order_id" name="invoice_id" type="hidden" value="" />
                        <input type="hidden" name="m" value="invoice">
                        <input type="hidden" name="a" value="check">
                        <table class="table" style="border:none;">
                            <tr>
                                <td style="border:none;text-align:right">审核结果：</td>
                                <td style="border:none;">
                                    <select name="is_agree" id="is_agree" style="width:300px;" class="form-control required">
                                        <option value="1">同意</option>
                                        <option value="2">拒绝</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td style="border:none;text-align:right">备注：</td>
                                <td style="border:none;">
                                    <textarea class="form-control required" id="dialog_description" name="description" placeholder="填写理由(非必填)"></textarea>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
                <div style="display:none" id="dialog-field-search" title="高级搜索">
                    <form class="form-inline" id="searchForm" action="" method="get">
                        <input type="hidden" name="daochu"  id="daochu"/>
                        <div id="search_add" style="width:650px;float:left;">
                            <empty name="fields_search">
                                <div id="con_search_1" style="float:left;width:650px;margin:0 10px 0 10px;">
                                    <ul class="nav pull-left" style="margin:0px 0 0 23px;width:650px">
                                        <li class="pull-left">
                                            <select id="field_1" style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition(1)" >
                                                <option class="" value="name">--请选择条件--</option>
                                                <option class="word" value="name">发票号码</option>
                                                <option class="word" value="contract_num">合同编号</option>
                                                <option class="contract_check" value="is_checked">审核状态</option>
                                                <option class="role" value="create_role_id">开票人</option>
                                                <option class="word" value="customer_name">客户名称</option>
                                                <option class="number" value="price">开票金额</option>
                                                <option class="date" value="invoice_time">开票日期</option>
                                                <option class="date" value="create_time">创建时间</option>
                                                <option class="date" value="update_time">修改时间</option>
                                            </select>&nbsp;&nbsp;
                                        </li>
                                        <li class="pull-left" id="conditionContent_1">
                                            <select id="condition_1" style="width:auto" class="form-control input-sm new-select" onchange="changeSearch()" name="name[condition]">
                                                <option value="contains">{:L('CONTAINS')}</option>
                                                <option value="is">{:L('IS')}</option>
                                                <option value="start_with">{:L('START_WITH')}</option>
                                                <option value="end_with">{:L('END_WITH')}</option>
                                                <option value="is_empty">{:L('IS_EMPTY')}</option>
                                            </select>&nbsp;&nbsp;
                                        </li>
                                        <li class="pull-left" id="searchContent_1">
                                            <input id="search_1" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="name[value]"/>&nbsp;&nbsp;
                                        </li>
                                    </ul>
                                </div>
                                <?php $max_key = 1;?>
                                <else />
                                <volist name="fields_search" key="key1" id="vo">
                                    <div id="con_search_{$key1}" style="float:left;width:650px;margin:0px 10px 0 10px;padding-top:10px;">
                                        <div id="rem_{$key1}" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="{$key1}" title="移除"><span class="fa fa fa-times-circle"></span></a></div>
                                        <ul class="nav pull-left" style="margin:0px 0 0 5px;width:620px;">
                                            <li class="pull-left">
                                                <select id="field_{$key1}" style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition({$key1})" >
                                                    <option class=""  value="name">--请选择条件--</option>
                                                    <option class="word" <if condition = "$vo['field'] eq 'name'">selected="selected"</if> value="name">发票号码</option>
                                                    <option class="word" <if condition = "$vo['field'] eq 'contract_num'">selected="selected"</if> value="contract_num">合同编号</option>
                                                    <option class="contract_check" <if condition = "$vo['field'] eq 'is_checked'">selected="selected"</if> value="is_checked">审核状态</option>
                                                    <option class="role" <if condition = "$vo['field'] eq 'create_role_id'">selected="selected"</if> value="create_role_id">开票人</option>
                                                    <option class="word" <if condition = "$vo['field'] eq 'customer_name'">selected="selected"</if> value="customer_name">客户名称</option>
                                                    <option class="number" <if condition = "$vo['field'] eq 'price'">selected="selected"</if> value="price">开票金额</option>
                                                    <option class="date" <if condition = "$vo['field'] eq 'invoice_time'">selected="selected"</if> value="invoice_time">创建时间</option>
                                                    <option class="date" <if condition = "$vo['field'] eq 'create_time'">selected="selected"</if> value="create_time">创建时间</option>
                                                    <option class="date" <if condition = "$vo['field'] eq 'update_time'">selected="selected"</if> value="update_time">修改时间</option>
                                                </select>&nbsp;&nbsp;
                                            </li>
                                            <li class="pull-left" id="conditionContent_{$key1}">
                                            <if condition="$vo.form_type eq 'number'">
                                                <select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
                                                    <option value="gt" <if condition="$_GET[$vo['field']][condition] eq 'gt'">selected="selected"</if>>{:L('GT')}</option>
                                                    <option value="lt" <if condition="$_GET[$vo['field']][condition] eq 'lt'">selected="selected"</if>>{:L('LT')}</option>
                                                    <option value="eq" <if condition="$_GET[$vo['field']][condition] eq 'eq'">selected="selected"</if>>{:L('EQ')}</option>
                                                    <option value="neq" <if condition="$_GET[$vo['field']][condition] eq 'neq'">selected="selected"</if>>{:L('NEQ')}</option>
                                                </select>
                                                <elseif condition="$vo.form_type eq 'datetime'"/>
                                                <select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
                                                    <option value="tgt" <if condition="$_GET[$vo['field']][condition] eq 'tgt'">selected="selected"</if>>{:L('PAST')}</option>
                                                    <option value="lt" <if condition="$_GET[$vo['field']][condition] eq 'lt'">selected="selected"</if>>{:L('BEFORE')}</option>
                                                    <option value="between" <if condition="$_GET[$vo['field']][condition] eq 'between'">selected="selected"</if>>{:L('IN')}</option>
                                                    <option value="nbetween" <if condition="$_GET[$vo['field']][condition] eq 'nbetween'">selected="selected"</if>>{:L('NOTIN')}</option>
                                                </select>
                                                <elseif condition="$vo.field eq 'create_role_id' || $vo.field eq 'is_checked' || $vo.form_type eq 'datetime'"/>
                                                <elseif condition="$vo.form_type eq 'box'" />
                                                <span id="{$vo['field']}"></span>
                                                <script type="text/javascript">
                                                    var b = '{$vo[field]}';
                                                    var c = 'product';
                                                    $.ajax({
                                                        type: 'get',
                                                        url: 'index.php?m=setting&a=boxfield&model=' + c + '&field=' + b,
                                                        async: false,
                                                        success: function (data) {
                                                            options = '';
                                                            $.each(data.data, function(k, v){
                                                            if ('{$vo.value}' == v){
                                                            select = 'selected';
                                                            } else{
                                                            select = '';
                                                            }
                                                            options += "<option value='" + v + "' " + select + ">" + v + "</option>";
                                                            });
                                                                    $("#{$vo['field']}").html('<select class="{$vo["field"]} form-control input-sm" style="width:auto" name="{$vo["field"]}" ><option value="">--{:L('PLEASE_CHOOSE')}--</option>' + options + '</select>&nbsp;&nbsp;');
                                                        },
                                                        dataType: 'json'
                                                    });
                                                    <if condition="!empty($_GET[$vo['field']])">
                            $(".{$vo['field']} option[value='{$_GET[$vo['field']]}']").attr('selected','selected');
                            </if>
                                                </script>
                                                <elseif condition="$vo.form_type eq 'address'" />
                                                <select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
                                                    <option value="contains" <if condition="$_GET[$vo['field']][condition] eq 'contains'">selected="selected"</if>>{:L('IN')}</option>
                                                    <option value="not_contain" <if condition="$_GET[$vo['field']][condition] eq 'not_contains'">selected="selected"</if>>{:L('NOTIN')}</option>
                                                </select>
                                                <select name="{$vo['field']}[state]" class="form-control input-sm" id="state" style="width:135px;"></select>
                                                <select name="{$vo['field']}[city]" class="form-control input-sm" id="city" style="width:110px;"></select>
                                                <select name="{$vo['field']}[area]" class="form-control input-sm" id="area" style="width:110px"></select>
                                                <input type="text" id="search" name="{$vo['field']}[search]" value="{$_GET[$vo['field']][search]}" class="form-control input-sm" placeholder="{:L('THE_STREET_INFORMATION')}" class="input-large">
                                                <script type="text/javascript">
                                                    new PCAS("{$vo['field']}[state]", "{$vo['field']}[city]", "{$vo['field']}[area]", "<php>echo $_GET[$vo['field']]['state'];</php>", "<php>echo $_GET[$vo['field']]['city'];</php>", "<php>echo $_GET[$vo['field']]['area'];</php>");
                                                </script>
                                                <else />
                                                <select id="condition" style="width:auto" class="form-control input-sm" name="{$vo['field']}[condition]">
                                                    <option value="contains" <if condition="$_GET[$vo['field']][condition] eq 'contains'">selected="selected"</if>>{:L('INCLUDE')}</option>
                                                    <option value="not_contain" <if condition="$_GET[$vo['field']][condition] eq 'not_contain'">selected="selected"</if>>{:L('EXCLUSIVE')}</option>
                                                    <option value="is" <if condition="$_GET[$vo['field']][condition] eq 'is'">selected="selected"</if>>{:L('YES')}</option>
                                                    <option value="isnot" <if condition="$_GET[$vo['field']][condition] eq 'isnot'">selected="selected"</if>>{:L('NO')}</option>
                                                    <option value="start_with" <if condition="$_GET[$vo['field']][condition] eq 'start_with'">selected="selected"</if>>{:L('BEGINNING_CHARACTER')}</option>
                                                    <option value="end_with" <if condition="$_GET[$vo['field']][condition] eq 'end_with'">selected="selected"</if>>{:L('TERMINATION_CHARACTER')}</option>
                                                    <option value="is_empty" <if condition="$_GET[$vo['field']][condition] eq 'is_empty'">selected="selected"</if>>{:L('MANDATORY')}</option>
                                                    <option value="is_not_empty" <if condition="$_GET[$vo['field']][condition] eq 'is_not_empty'">selected="selected"</if>>{:L('ISNOTEMPTY')}</option>
                                                </select>
                                            </if>
                                            </li>
                                            <li class="pull-left" id="searchContent_{$key1}" style="margin-left:5px;">
                                            <if condition="$vo.form_type neq 'box' && $vo.form_type neq 'address'">
                                                <if condition="$vo.form_type eq 'datetime'">
                                                    <input id="start_{$vo['field']}" type="text" class="form-control input-sm search-query" name="{$vo['field']}[start]" onclick="WdatePicker()" value="{$fields_search[$vo['field']][start]}" rel="invoice"/> 至 <input id="end_{$vo['field']}" type="text" class="form-control input-sm search-query" name="{$vo['field']}[end]" onclick="WdatePicker()" value="{$fields_search[$vo['field']][end]}" rel="invoice"/>
                                                    <elseif condition="$vo['field'] eq 'create_role_id'"/>
                                                    <span id="owner_role_search" rel="{$key1}" rel1="{$vo['field']}[value]" rel2="{$_GET[$vo['field']][value]}"/>
                                                    <script type="text/javascript">
                                                        var key_id = $('#owner_role_search').attr('rel');
                                                        var search_create_role_id = $('#owner_role_search').attr('rel1');
                                                        var owner_roleid = $('#owner_role_search').attr('rel2');
                                                        $.ajax({
                                                            type: 'get',
                                                            url: 'index.php?m=user&a=getrolelist',
                                                            async: false,
                                                            success: function (data) {
                                                                options = '';
                                                                $.each(data.data, function (k, v) {
                                                                    options += '<option value="' + v.role_id + '" checkedit>' + v.user_name + ' [' + v.department_name + '-' + v.role_name + '] </option>';
                                                                });
                                                                $("#searchContent_" + key_id + "").html('<select class="selectpicker show-tick form-control input-sm" data-live-search="true" id="search_' + key_id + '" name="' + search_create_role_id + '" style="width:auto">' + options + '</select>');
                                                                var owner_roleid = "{$_GET[$vo['field']][value]}";
                                                                $('#search_' + key_id + ' option[value=' + owner_roleid + ']').prop('selected', true);
                                                            },
                                                            dataType: 'json'
                                                        });
                                                    </script>
                                                    <elseif condition="$vo['field'] eq 'is_checked'"/>
                                                    <select class="form-control input-sm" style="width:auto" name="{$vo['field']}[value]">
                                                        <option value="0">待审</option>
                                                        <option value="1" <if condition ="$_GET[$vo['field']][value] eq 1">selected="selected"</if> >通过</option>
                                                        <option value="2" <if condition ="$_GET[$vo['field']][value] eq 2">selected="selected"</if> >拒绝</option>
                                                    </select>
                                                    <else/>
                                                    <input name="{$vo['field']}[value]" type="text" class="form-control input-sm" class="{$vo['form_type']}" value="{$_GET[$vo['field']][value]}" rel="product">
                                                </if>
                                            </if>
                                            </li>
                                        </ul>
                                    </div>
                                    <?php $max_key = ++$key1;?>
                                </volist>
                            </empty>
                        </div>
                        <input type="hidden" name="this_page" value="{$this_page}" />
                        <div class="clearfix"></div>
                        <div style="margin-left: 35px;margin-top:0px;"><a href="javascript:void(0);" style="display: -moz-stack;margin: 30px 0px 0px; font-size: 12px; color: rgb(62, 133, 233);" id="add_btn">+添加筛选条件</a>
                        </div>
                        <div class="pull-right" class="button_type" style="margin:20px;">
                            <input type="hidden" name="m" value="invoice"/>
                            <input type="hidden" name="act" id="act" value="index"/>
                            <if condition="$Think.get.by neq null">
                                <input type="hidden" name="by" value="{$Think.get.by}"/>
                            </if>
                        </div>
                    </form>
                </div>

                <div style="display:none" id="dialog-edit">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-examine">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-count">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-return">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-bill">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-refund">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-assign">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-refuse">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>
                <div style="display:none" id="dialog-sendout">
                    <div class="spiner-example">
                        <div class="sk-spinner sk-spinner-three-bounce">
                            <div class="sk-bounce1"></div>
                            <div class="sk-bounce2"></div>
                            <div class="sk-bounce3"></div>
                        </div>
                    </div>
                </div>



            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    //筛选事件，同步刷新
    $("#shaixuan").on('click',function () {
        var type_business = $("#type_business").val();
        var applyed_time = $("#applyed_time").val();
        var applyed_endtime = $("#applyed_endtime").val();
        var type = $("#type").val();
        window.location.href = "{:U('invoice/index', 'type=')}" + type+"&type_business="+type_business+"&applyed_time="+applyed_time+"&applyed_endtime="+applyed_endtime;
    });

    $("#dialog-edit").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 620,
        position: ["center", 100],
        title: "发票",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#edit_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-examine").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "审批发票",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#examine_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-count").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "开票",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#count_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-return").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "回退",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#return_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-bill").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "收款",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                var amount = $("input[name='amount']").val();
                if (amount == "") {
                    alert_crm("请输入正确的金额！");
                    return false;
                }
                $('#bill_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-refund").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "退票",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#refund_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-assign").dialog({
        autoOpen: false,
        modal: true,
        width: 660,
        maxHeight: 720,
        position: ["center", 100],
        title: "业绩分配",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#assign_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-refuse").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "退款",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#refuse_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });
    $("#dialog-sendout").dialog({
        autoOpen: false,
        modal: true,
        width: 600,
        maxHeight: 420,
        position: ["center", 100],
        title: "发放",
        close: function () {
            //selectStatus();//更新
            $(this).html("");
        },
        buttons: {
            "确定": function () {
                $('#sendout_form').submit();
                $(this).dialog("close");
            },
            "取消": function () {
//                selectStatus();//更新
                $(this).dialog("close");
            }
        }
    });

    $(function () {
        //编辑发票
        $(".btn_edit").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-edit').dialog('open');
            $('#dialog-edit').load("/index.php?m=invoice&a=editer&id=" + id);
        })

        //审批发票
        $(".btn_examine").on("click", function () {
            var id = 0;
            var type = $(this).attr("data_type");
            if (type === "multi") {
                //多个审批
                id = $(this).closest(".breadcrum").find(".select_arr").val();
            }
            if (type === "single") {
                //单独审批
                id = $(this).attr("data-id");
            }
            $('#dialog-examine').dialog('open');
            $('#dialog-examine').load("/index.php?m=invoice&a=examine&id=" + id);
        })
        //撤销发票
        $(".btn_delete").click(function () {
            var id = 0;
            var title = "";
            var type = $(this).attr("data_type");
            if (type === "multi") {
                //批量撤销
                id = $(this).closest(".breadcrum").find(".select_arr").val();
                title = "确定要撤销选中的发票吗？";
            }
            if (type === "single") {
                //单独撤销
                id = $(this).attr("data-id");
                title = "确定要撤销该发票吗？";
            }
            swal({
                title: title,
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            },
                    function () {
                        window.location.href = "{:U('invoice/revoke', 'invoice_id=')}" + id;
                    })
        });
        //批量通过
        $('.btn_passed').click(function () {
            var id = 0;
            var title = "";
            id = $(this).closest(".breadcrum").find(".select_arr").val();
            title = "确定要通过选中的发票吗？";
            swal({
                    title: title,
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    closeOnConfirm: false
                },
                function () {
                    window.location.href = "{:U('invoice/examine_all', 'invoice_id=')}" + id;
                })
        });
        //开票
        $(".btn_count").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-count').dialog('open');
            $('#dialog-count').load("/index.php?m=invoice&a=count&id=" + id);
        })
        //回退
        $(".btn_return").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-return').dialog('open');
            $('#dialog-return').load("/index.php?m=invoice&a=goback&id=" + id);
        })
        //收款
        $(".btn_bill").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-bill').dialog('open');
            $('#dialog-bill').load("/index.php?m=invoice&a=bill&id=" + id);
        })
        //退票
        $(".btn_refund").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-refund').dialog('open');
            $('#dialog-refund').load("/index.php?m=invoice&a=refund&id=" + id);
        })
        //业绩分配-传统
        $(".btn_assign").on("click", function () {
            var type = $(this).attr("data-type");
            var id = $(this).attr("data-id");
            $('#dialog-assign').dialog('open');
            if (type == "传统项目") {
                $('#dialog-assign').load("/index.php?m=invoice&a=distribution&id=" + id);
            } else {
                $('#dialog-assign').load("/index.php?m=invoice&a=distribution_int&id=" + id);
            }
        })

        //退款
        $(".btn_refuse").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-refuse').dialog('open');
            $('#dialog-refuse').load("/index.php?m=invoice&a=refuse&id=" + id);
        })
        //发放
        $(".btn_sendout").on("click", function () {
            var id = $(this).attr("data-id");
            $('#dialog-sendout').dialog('open');
            $('#dialog-sendout').load("/index.php?m=invoice&a=sendout&id=" + id);
        })




        $("input[name='checkall']").click(function () {
            var st = $(this).closest(".tab-content").attr("id");
            $("#" + st + " input[name='checklist']").prop('checked', $(this).prop("checked"));
            var i = 0;
            var id_array = new Array();
            $("#" + st + " input[name='checklist']").each(function () {
                if ($(this).prop("checked")) {
                    i++;
                    id_array.push($(this).val());
                }
            })
            if (i > 0) {
                $("#" + st + " .titlebtns").show();
                $("#" + st + " .notitlebtns").hide();
                $("#" + st + " .icheck_num").html(i);
                $("#" + st + " .select_arr").val(id_array);
            } else {
                $("#" + st + " .titlebtns").hide();
                $("#" + st + " .notitlebtns").show();
            }
        })

        $("input[name='checklist']").click(function () {
            var st = $(this).closest(".tab-content").attr("id");
            var i = 0;
            var id_array = new Array();
            $("#" + st + " input[name='checklist']").each(function () {
                if ($(this).prop("checked")) {
                    i++;
                    id_array.push($(this).val());
                }
            })

            if (i > 0) {
                $("#" + st + " .titlebtns").show();
                $("#" + st + " .notitlebtns").hide();
                $("#" + st + " .icheck_num").html(i);
                $("#" + st + " .select_arr").val(id_array);
            } else {
                $("#" + st + " .titlebtns").hide();
                $("#" + st + " .notitlebtns").show();
            }
        })

        $(".btnclose").click(function () {
            $(".titlebtns").hide();
            $(".notitlebtns").show();
        })
    })


    if ("{:C('isMobile')}" == "1") {
        width = $('.container').width() * 0.9;
    } else {
        width = 800;
    }

    var tab = "{$_GET['tab']}";
    var hreflist = $(".navContent li a");
    if (tab) {
        $(".tab-content").hide();
        $("." + tab + "").show();
        hreflist.each(function () {
            if ($(this).attr("rel") == tab) {
                $(".navContent li a span").removeClass("li_text_active");
                $(".navContent li a span").addClass("li_text");
                $(this).find("span").removeClass("li_text");
                $(this).find("span").addClass("li_text_active");
            }
        })
    } else {
        $(".tab-content").hide();
        $(".tab0").show();
        hreflist.each(function () {
            if ($(this).attr("rel") == 'tab0') {
                $(".navContent li a span").removeClass("li_text_active");
                $(".navContent li a span").addClass("li_text");
                $(".navContent li a span").eq(0).removeClass("li_text");
                $(".navContent li a span").eq(0).addClass("li_text_active");
            }
        })
    }

    /*让复选框默认取消选择*/
    var is_receivables = '{$is_receivables}';
    $(':checkbox').prop('checked', false);

    $("#edit_invoice").click(function () {
        window.location.href = "{:U('invoice/edit', 'id=')}" + $(this).attr('rel');
    });
    $("#short_search").val('{$Think.get.search}');

    $("#check_invoice").click(function () {
        var is_checked = $('#is_checked').val();
        var id = $(this).attr('rel');
        if (is_checked == 1) {
            var order_id = $(this).attr('rel');
            $("#dialog_order_id").val(order_id);
            $('#dialog-check-invoice').dialog('open');
            $("#dialog_description").focus();
        } else {
            swal({
                title: "确定要撤销审核吗？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            },
                    function () {
                        window.location.href = "{:U('invoice/revokeCheck', 'invoice_id=')}" + id;
                    });
        }
    });

    $("#dialog-check-invoice").dialog({
        autoOpen: false,
        modal: true,
        width: 444,
        maxHeight: 460,
        position: ["center", 100],
        buttons: {
            "确定": function () {
                $('#contract_dialog').submit();
                $(this).dialog("close");
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });

    $("#dialog-role-info").dialog({
        autoOpen: false,
        modal: true,
        width: width,
        maxHeight: 550,
        position: ["center", 100]
    });


    /**添加筛选条件**/
    var m = {$max_key};
    $('#add_btn').click(function () {
        m += 1;
                $('#search_add').append('<div id="con_search_' + m + '" style="float:left;width:450px;padding-top:10px;margin:0px 10px 0 10px;"><div  id="rem_' + m + '" class="pull-left" style="line-height:30px;"><a href="javascript:void(0);" class="rem_search" rel="' + m + '" title="移除"><span class="fa fa-times-circle"></span></a></div>&nbsp;<ul class="nav pull-left" style="margin:0px 0 0 5px;width:420px"><li class="pull-left"><select id="field_' + m + '"  style="width:auto" class="form-control input-sm field_name new-select" onchange="changeCondition(' + m + ')" name=""><option class="" value="name">--请选择条件--</option><option class="word" value="name">发票号码</option><option class="word" value="contract_num">合同编号</option><option class="contract_check" value="is_checked">审核状态</option><option class="role" value="create_role_id">开票人</option><option class="word" value="customer_name">客户名称</option><option class="number" value="price">开票金额</option><option class="date" value="invoice_time">开票日期</option><option class="date" value="create_time">创建时间</option><option class="date" value="update_time">修改时间</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="conditionContent_' + m + '"><select id="condition_' + m + '" style="width:auto" class="form-control input-sm new-select" name="condition" onchange="changeSearch()"><option value="contains">{:L('CONTAINS')}</option><option value="is">{:L('IS')}</option><option value="start_with">{:L('START_WITH')}</option><option value="end_with">{:L('END_WITH')}</option><option value="is_empty">{:L('IS_EMPTY')}</option></select>&nbsp;&nbsp;</li><li class="pull-left" id="searchContent_' + m + '"><input id="search_' + m + '" type="text" style="width:160px;" class="input-medium form-control input-sm search-query" name="search"/>&nbsp;&nbsp;</li></ul></div>');
    });
    $(document).on('click', '.rem_search', function () {
        var num = $(this).attr('rel');
        $('#con_search_' + num).remove();
    });

    // 筛选重复判断
    var dosearch = 1;
    function doh() {
        var ary = new Array();
        var field_name = '';
        var is_submit = 1;
        $('.field_name').each(function (k, v) {
            field_name = $(this).find("option:selected").val();
            if (jQuery.inArray(field_name, ary) >= 0) {
                is_submit = 0;
                swal({
                    title: "筛选条件中有重复项！",
                    text: data.info,
                    type: "error"
                });
                dosearch = 0;
                return false;
            }
            ary[k] = field_name;
        })
        if (is_submit == 1) {
            $("#searchForm").submit();
        }
    }

    $("#dialog-field-search").dialog({
        autoOpen: false,
        width: 700,
        modal: true,
        height: 350,
        position: ["center", 100],
        buttons: {
            "确定": function () {
                doh();
                if (dosearch == 1) {
                    $(this).dialog("close");
                }
            },
            "取消": function () {
                $(this).dialog("close");
            }
        }
    });
    $("#search_type").click(function () {
        $("#dialog-field-search").dialog('open');
    })


    $(function () {

        $('#delete').click(function () {
            var id_array = new Array();
            $("input.check_list:checked").each(function () {
                id_array.push($(this).val());
            });
            if (id_array.length == 0) {
                alert_crm('您没有选中任何客户！');
                return false;
            }
            swal({
                title: "您确定要删除发票信息吗？",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "是的，我要删除！",
                cancelButtonText: '让我再考虑一下…',
                closeOnConfirm: false,
                closeOnCancel: false
            },
                    function (isConfirm) {
                        if (isConfirm) {
                            $.ajax({
                                type: 'post',
                                url: "{:U('invoice/delete')}",
                                data: {invoice_id: id_array},
                                async: false,
                                success: function (data) {
                                    if (data.status == 1) {
                                        swal("删除成功！", "您已经永久删除了信息！", "success");
                                        location.reload();
                                    } else {
                                        swal({
                                            title: "操作失败！",
                                            text: data.info,
                                            type: "error"
                                        })
                                        return false;
                                    }
                                },
                                dataType: 'json'
                            });
                        } else {
                            swal("已取消", "您取消了删除操作！", "error");
                        }
                    });
        });
        $("#dosearch").click(function () {
            result = checkSearchForm();
            if (result) {
                $("#act").val('search');
                $("#searchForm").submit();
            }
        });
//        var limit_size = 1000;
//        var count = 0;
//
//        $("#excelExport").click(function(){
//            if(count > limit_size){
//                if(confirm('当前导出量过大，将分几次导出，可能需要您等待一段时间，是否继续?')){
//                    remainTime();
//                }
//            }else{
//                var id_array = new Array();
//                $("input[class='check_list']:checked").each(function() {
//                    id_array.push($(this).val());
//                });
//                if(id_array !=''){
//                    if(confirm("{:L('ARE_YOU_SURE_YOU_WANT_TO_EXPORT_THE_BUSINESS_OPPORTUNITIES')}")){
//                        remainTime();
//                    }
//                }else{
//                    if(confirm("确定要导出全部吗？")){
//                        remainTime();
//                    }
//                }
//            }
//        });
    });
    var limit_size = 1000;
    var ii = 1;
    var count = '{$count}';
    $(".excelExport").click(function () {
        if (ii == -1) {
            ii = 1;
        }
        var id_array = new Array();
        $("input.check_list:checked").each(function () {
            id_array.push($(this).val());
        });
        if (id_array) {
            $("#daochu").val(id_array);
        }
//        alert(id_array);
        $("#act").val('excel');
        $("#current_page").val(ii);
        $("#export_limit").val(limit_size);
        $("#searchForm").submit();
    })
</script>
<include file="Public:footer" />


